'use strict';
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  /**
   * 上传文件
   */
  router.post('/api/upload/file', controller.upload.file);

  /**
   * 用户权限相关
   */
  router.post('/api/user/login', controller.user.login);
  router.post('/api/user/register', controller.user.register);
  router.put('/api/user/updatePassword', controller.user.updatePassword);
  router.post('/api/user/updateUserRoles', controller.user.updateUserRoles);
  router.get('/api/user/getUserRoles', controller.user.getUserRoles);
  router.get('/api/user/getUserInfo', controller.user.getUserInfo);
  router.resources('user', '/api/user', controller.user);
  // 角色
  router.get('/api/role/list', controller.role.allList);
  router.resources('role', '/api/role', controller.role);
  // 菜单
  router.get('/api/menu/list', controller.menu.allList);
  router.resources('menu', '/api/menu', controller.menu);
  /**
   * 企业
   */
  router.get('/api/enterprise/list', controller.enterprise.allList);
  router.resources('enterprise', '/api/enterprise', controller.enterprise);

  /**
   * 图书馆预约系统 - 后台管理API
   */
  // 学校管理
  router.get('/api/miniProgramUsers/list', controller.miniProgramUsers.allList);
  router.resources('miniProgramUsers', '/api/miniProgramUsers', controller.miniProgramUsers);
  
  // 学校管理
  router.get('/api/schools/list', controller.schools.allList);
  router.resources('schools', '/api/schools', controller.schools);
  
  // 学生管理
  router.get('/api/students/list', controller.students.allList);
  router.resources('students', '/api/students', controller.students);
  
  // 图书馆管理
  router.get('/api/libraries/list', controller.libraries.allList);
  router.resources('libraries', '/api/libraries', controller.libraries);
  
  // 图书馆楼层管理
  router.get('/api/libraryFloors/list', controller.libraryFloors.allList);
  router.resources('libraryFloors', '/api/libraryFloors', controller.libraryFloors);
  
  // 图书馆区域管理
  router.get('/api/libraryAreas/list', controller.libraryAreas.allList);
  router.resources('libraryAreas', '/api/libraryAreas', controller.libraryAreas);
  
  // 座位管理
  router.get('/api/seats/list', controller.seats.allList);
  router.resources('seats', '/api/seats', controller.seats);
  
  // 轮播图管理
  router.get('/api/carousels/list', controller.carousels.allList);
  router.resources('carousels', '/api/carousels', controller.carousels);
  
  // 资讯管理
  router.get('/api/news/list', controller.news.allList);
  router.resources('news', '/api/news', controller.news);
  
  // 预约记录管理
  router.get('/api/reservations/list', controller.reservations.allList);
  router.resources('reservations', '/api/reservations', controller.reservations);
  
  /**
   * 图书馆预约系统 - 小程序API
   */
  // 小程序用户
  router.post('/api/mini/login', controller.miniProgramUsers.login);
  router.post('/api/mini/bindStudent', controller.miniProgramUsers.bindStudent);
  router.get('/api/mini/getUserInfo', controller.miniProgramUsers.getUserInfo);
  
  // 小程序首页
  router.get('/api/mini/carousels', controller.miniProgramUsers.getCarousels);
  router.get('/api/mini/news', controller.miniProgramUsers.getNews);
  router.get('/api/mini/newsDetail', controller.miniProgramUsers.getNewsDetail);
  
  // 小程序预约
  router.get('/api/mini/schools', controller.miniProgramUsers.getSchools);
  router.get('/api/mini/libraries', controller.miniProgramUsers.getLibraries);
  router.get('/api/mini/libraryDetail', controller.miniProgramUsers.getLibraryDetail);
  router.get('/api/mini/floors', controller.miniProgramUsers.getFloors);
  router.get('/api/mini/areas', controller.miniProgramUsers.getAreas);
  router.get('/api/mini/seats', controller.miniProgramUsers.getSeats);
  router.post('/api/mini/reserve', controller.miniProgramUsers.reserve);
  
  // 小程序预约记录
  router.get('/api/mini/reservations', controller.miniProgramUsers.getReservations);
  router.post('/api/mini/checkIn', controller.miniProgramUsers.checkIn);
  router.post('/api/mini/checkOut', controller.miniProgramUsers.checkOut);
  router.post('/api/mini/cancelReservation', controller.miniProgramUsers.cancelReservation);
};
